<?php

declare(strict_types=1);

use Hyperf\HttpServer\Router\Router;

Router::addGroup('/endapi/', function () {
    // 登录
    Router::post('login', 'AdminBundle\Http\Controllers\Admin\V1\AdminController@login', ['name' => '用户登录', 'alias' => 'endapi.login']);
    // 刷新
    Router::post('refresh', 'AdminBundle\Http\Controllers\Admin\V1\AdminController@refresh', ['name' => '刷新Token', 'alias' => 'endapi.refresh']);
});

Router::addGroup('/endapi/', function () {
    // 退出
    Router::post('logout', 'AdminBundle\Http\Controllers\Admin\V1\AdminController@logout', ['name' => '退出登录', 'alias' => 'endapi.logout']);
    Router::get('menu/list', 'AdminBundle\Http\Controllers\Admin\V1\MenuController@index', ['name' => '获取菜单列表', 'alias' => 'endapi.menu.list']);
    Router::get('menu/getroutes', 'AdminBundle\Http\Controllers\Admin\V1\MenuController@getroutes', ['name' => '获取菜单路由', 'alias' => 'endapi.menu.getroutes']);
    Router::get('menu/permissions_list', 'AdminBundle\Http\Controllers\Admin\V1\MenuController@getPermissions', ['name' => '获取菜单权限列表', 'alias' => 'endapi.menu.permissionsList']);
    Router::post('menu/store', 'AdminBundle\Http\Controllers\Admin\V1\MenuController@store', ['name' => '新增保存菜单', 'alias' => 'endapi.menu.store']);
    Router::get('menu/get_info/{id:\d+}', 'AdminBundle\Http\Controllers\Admin\V1\MenuController@getInfo', ['name' => '查看菜单详细信息', 'alias' => 'endapi.menu.getInfo']);
    Router::post('menu/order', 'AdminBundle\Http\Controllers\Admin\V1\MenuController@orderMenu', ['name' => '菜单排序', 'alias' => 'endapi.menu.order']);
    Router::post('menu/delete/{id:\d+}', 'AdminBundle\Http\Controllers\Admin\V1\MenuController@destroy', ['name' => '删除菜单', 'alias' => 'endapi.menu.delete']);

    Router::get('admin/list', 'AdminBundle\Http\Controllers\Admin\V1\AdminController@index', ['name' => '查看管理员', 'alias' => 'endapi.admin.list']);
    Router::get('admin/info', 'AdminBundle\Http\Controllers\Admin\V1\AdminController@info', ['name' => '查看管理员详细信息', 'alias' => 'endapi.admin.info']);
    Router::get('admin/get_info/{id:\d+}', 'AdminBundle\Http\Controllers\Admin\V1\AdminController@getInfo', ['name' => '查看管理员详细信息', 'alias' => 'endapi.admin.getInfo']);
    Router::get('admin/get_roles', 'AdminBundle\Http\Controllers\Admin\V1\AdminController@getRoles', ['name' => '获取管理员角色', 'alias' => 'endapi.admin.getRoles']);
    Router::post('admin/store', 'AdminBundle\Http\Controllers\Admin\V1\AdminController@store', ['name' => '新增修改管理员', 'alias' => 'endapi.admin.store']);
    Router::post('admin/delete/{id:\d+}', 'AdminBundle\Http\Controllers\Admin\V1\AdminController@destroy', ['name' => '删除管理员', 'alias' => 'endapi.admin.delete']);
    Router::post('admin/change_pwd', 'AdminBundle\Http\Controllers\Admin\V1\AdminController@changePwd', ['name' => '修改密码', 'alias' => 'endapi.admin.changePwd']);

    Router::get('roles/list', 'AdminBundle\Http\Controllers\Admin\V1\RolesController@index', ['name' => '角色列表', 'alias' => 'endapi.roles.list']);
    Router::post('roles/store', 'AdminBundle\Http\Controllers\Admin\V1\RolesController@store', ['name' => '添加修改角色', 'alias' => 'endapi.roles.store']);
    Router::get('roles/get_info/{id:\d+}', 'AdminBundle\Http\Controllers\Admin\V1\RolesController@getInfo', ['name' => '获取角色详细信息', 'alias' => 'endapi.roles.getInfo']);
    Router::post('roles/delete/{id:\d+}', 'AdminBundle\Http\Controllers\Admin\V1\RolesController@destroy', ['name' => '删除角色', 'alias' => 'endapi.roles.delete']);
    Router::get('roles/get_permissions/{id:\d+}', 'AdminBundle\Http\Controllers\Admin\V1\RolesController@getPermissions', ['name' => '获取权限', 'alias' => 'endapi.roles.getPermissions']);
    Router::post('roles/save_permissions', 'AdminBundle\Http\Controllers\Admin\V1\RolesController@savePermissions', ['name' => '保存权限', 'alias' => 'endapi.roles.savePermissions']);
    Router::get('roles/get_users', 'AdminBundle\Http\Controllers\Admin\V1\RolesController@getUsers', ['name' => '获取用户角色', 'alias' => 'endapi.roles.getUsers']);
    Router::get('roles/search_user', 'AdminBundle\Http\Controllers\Admin\V1\RolesController@searchUser', ['name' => '查询用户角色', 'alias' => 'endapi.roles.searchUser']);
    Router::post('roles/save_user', 'AdminBundle\Http\Controllers\Admin\V1\RolesController@saveUser', ['name' => '保存用户角色', 'alias' => 'endapi.roles.saveUser']);
    Router::post('roles/remove_user', 'AdminBundle\Http\Controllers\Admin\V1\RolesController@removeUser', ['name' => '移除用户角色', 'alias' => 'endapi.roles.removeUser']);

    Router::get('permission/user_permissions', 'AdminBundle\Http\Controllers\Admin\V1\PermissionController@getUserPermissions', ['name' => '查看用户权限', 'alias' => 'endapi.permission.userPermissions']);
    Router::get('permission/list', 'AdminBundle\Http\Controllers\Admin\V1\PermissionController@index', ['name' => '获取权限列表', 'alias' => 'endapi.permission.list']);
    Router::post('permission/store', 'AdminBundle\Http\Controllers\Admin\V1\PermissionController@store', ['name' => '权限更新', 'alias' => 'endapi.permission.store']);
    Router::get('permission/get_info/{id:\d+}', 'AdminBundle\Http\Controllers\Admin\V1\PermissionController@getInfo', ['name' => '获取权限详细信息', 'alias' => 'endapi.permission.getInfo']);
    Router::post('permission/order', 'AdminBundle\Http\Controllers\Admin\V1\PermissionController@orderPermissions', ['name' => '权限排序', 'alias' => 'endapi.permission.order']);
    Router::post('permission/delete/{id:\d+}', 'AdminBundle\Http\Controllers\Admin\V1\PermissionController@destroy', ['name' => '权限删除', 'alias' => 'endapi.permission.delete']);

    // 获取用户信息
    Router::get('user', 'AdminBundle\Http\Controllers\Admin\V1\AdminController@user');
}, [
    'middleware' => [
        AdminBundle\Middleware\Auth\LoginAuthMiddleware::class,
        AdminBundle\Middleware\Auth\AdminAuthMiddleware::class,
    ],
]);

Router::addGroup('/endapi/', function () {
    Router::get('admin/profile', 'AdminBundle\Http\Controllers\Admin\V1\AdminController@profile');
    Router::post('admin/save_profile', 'AdminBundle\Http\Controllers\Admin\V1\AdminController@saveProfile');
}, [
    'middleware' => [
        AdminBundle\Middleware\Auth\LoginAuthMiddleware::class
    ],
]);